package mock;
import model.interfaces.Rule;


public class MaxParfumNumberRule implements Rule {
	
	private int maxParfumNumber;
	private int currentParfumNumber;
	
	public MaxParfumNumberRule(int maxParfumNumber) {
		if (maxParfumNumber < 0) {
			throw new IllegalArgumentException("parfumNumber must be non-negative");
		}
		this.maxParfumNumber = maxParfumNumber;
		this.currentParfumNumber = 0;
	}

	@Override
	public void addObject(Object object) {
		if (object instanceof Parfum) {
			this.currentParfumNumber++;
		}
	}

	@Override
	public boolean verify() {
		return currentParfumNumber <= maxParfumNumber;
	}

	@Override
	public void reset() {
		this.currentParfumNumber = 0;
	}

}
